package com.xyzwps.harbor.handler.demo;

import static com.xyzwps.harbor.handler.FiltersHelper.compose;
import static org.springframework.http.MediaType.APPLICATION_JSON;
import static org.springframework.web.reactive.function.server.RequestPredicates.accept;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.server.RouterFunctions;

@Component
public class DemoRoutes {

    @Autowired
    private DemoHandler demo;

    public void routes(RouterFunctions.Builder builder) {
        builder.nest(accept(APPLICATION_JSON), b -> b
                .GET("/", demo::hello)
                .GET("/hello-world", demo::hello)
                .GET("/false", demo::hello)
                .GET("/auth", compose(demo::hello, demo::demoFilter))
        );
    }
}